#coding:utf-8

from flask import Flask, make_response, request
app = Flask(__name__)


@app.route('/set_cookie')
def set_cookie():
    resp = make_response('success')
    #todo 设置cookie,默认有效期是临时cookie,关闭浏览器就失效
    resp.set_cookie('Itcast','Python')
    #todo max_age设置有效期,单位:秒
    resp.set_cookie('Itcast2', 'Python2', max_age=3600)
    return resp


@app.route('/get_cookie')
def get_cookie():
    #todo 获取cookie
    c = request.cookies.get('Itcast')
    return c


@app.route('/delete_cookie')
def delete_cookie():
    resp = make_response('del success')
    #todo 删除cookie
    resp.delete_cookie('Itcast1')
    return resp


if __name__ == '__main__':
    app.run()